package com.xywy.fwc.net;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.xywy.fwc.bean.DoctorBean;
import com.xywy.fwc.bean.DoctorBeanInfo;
import com.xywy.fwc.bean.FwcAssea;

public class DoctorBeanInfoParser extends BaseParser<DoctorBeanInfo> {

	@Override
	public DoctorBeanInfo parseJson(String result) {
		try {
			DoctorBeanInfo docinfo = new DoctorBeanInfo();
			JSONObject data = new JSONObject(result);
			JSONObject json = data.optJSONObject("data");
			docinfo.setTotalpage(json.optInt("totalpage"));
			docinfo.setPage(json.optInt("page"));
			JSONArray array = json.optJSONArray("list");
//			for(int i=0;i<array.length();i++){
//				JSONObject jo = (JSONObject) array.get(i);
//				System.out.println(jo.get("assoc_member").getClass());
//			}
			System.out.println(result);
			Gson gson = new Gson();
			ArrayList<DoctorBean> list = gson.fromJson(json.optJSONArray("list").toString(), new TypeToken<List<DoctorBean>>(){}.getType());
			System.out.println(list.size());
			docinfo.setDoctorbeans(list);
			return docinfo;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

}
